//
//  EpointTask.m
//  EpointFrameCore
//
//  Created by 李亚春 on 13-12-4.
//  Copyright (c) 2013年 Epoint. All rights reserved.
//

#import "EpointTask.h"
#import "TKAlertCenter.h"

@implementation EpointTask

-(id)initWithContext:(id<EpointUIBaseProtocol>)_ctx andParams:(NSMutableDictionary *)_passparams andTaskId:(int)taskId
{
    self = [super init];
    if (self) {
        context = _ctx;
        params = _passparams;
        TaskId = taskId;
    }
    return self;
}

-(void)startInvokeTask
{
    [NSThread detachNewThreadSelector:@selector(execute) toTarget:self withObject:nil];
}

-(void)execute{};

-(void)sendDataRefreshUI:(NSObject *)data
{
    dispatch_sync(dispatch_get_main_queue(), ^{
        [context refreshUIWithThreadGuid:TaskId andData:data];
    });
}

-(void)dealloc
{
    params = nil;
    context = nil;
}

-(void)toastInTask:(NSString *)msg
{
    dispatch_sync(dispatch_get_main_queue(), ^{
        [[TKAlertCenter defaultCenter] postAlertWithMessage:msg];
    });
}

@end
